//
//  TicketResultService.m
//  NetTest
//
//  Created by mac on 12-5-11.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "TicketResultService.h"

@implementation TicketResultService
-(id)init{
    if ([super init]) {
        tablePK_=@"sectionID";
        tablename_=@"T_TicketResult";
    }
    return self;
}

//-(BaseModel*)getModel:(NSString *)pkid{
//    NSString *sql=[NSString stringWithFormat: @"select sectionID,result,type from %@ where %@=\'%@\'",tablename_,tablePK_,pkid];
//    
//    sqlite3_stmt * stmt = [Sqlite3Helper execQuery:sql];
//    
//    TicketResult* result=nil;
//    
//    if (stmt!=nil) {
//        result =[[[TicketResult alloc] init] autorelease];
//        if(sqlite3_step(stmt)==SQLITE_ROW) {
//            char* selectionID =  (char*)sqlite3_column_text(stmt,0);
//            char* cresult =(char*)sqlite3_column_text(stmt, 1);
//            
//            int typ=sqlite3_column_int(stmt, 3);
//            
//            result.sectionID=[NSString stringWithUTF8String:selectionID];
//            result.result=[NSString stringWithUTF8String:cresult];
//            
//            result.type=[NSNumber numberWithInt:typ];
//        }
//        
//        sqlite3_finalize(stmt);
//    }
//    return result;
//}

-(id)getModel:(NSString *)pkid{
    return [super getModel:pkid returnClass:NSClassFromString(@"TicketResult")];
}

-(NSMutableArray*)getCollection:(NSString *)strWhere{
    return [super getCollection:strWhere returnClass:NSClassFromString(@"TicketResult")];
}

-(NSMutableArray*)getCollection:(NSString *)strWhere orderby:(NSString *)orderby startIndex:(int)startIndex count:(int)count{
    
    return [super getCollection:strWhere orderby:orderby startIndex:startIndex count:count cls:NSClassFromString(@"TicketResult")];
}

-(NSMutableArray*)getAll{
    return [self getCollection:nil];
}

#pragma mark User Method
-(TicketResult*)getLast{
    NSMutableArray *arr=[self getCollection:nil orderby:@"SectionID desc" startIndex:0 count:1];
    if (arr!=nil&&arr.copy>0) {
        return [arr objectAtIndex:0];
    }
    else{
        return nil;
    }
}

@end
